> fread(fileText, 1, count, theFile);
I see from the rest of your code that you're reading a text file.
Some points.
1. You don't look at the return result of fread
2. You don't put a \0 at the end to make it a string
3. You don't allocate space for this \0
So perhaps
Code:
while( fread(temp, 1, 1,theFile) == 1 )
{
count++;
}
filetext = new char[count+1];
rewind(theFile);
int n = fread(filetext, 1, count, theFile);
if ( n > 0 ) filetext[n] = '\0'
> delete(filetext);
1. You do it in TWO places, so you're likely to end up deleting it twice (which is worse than not deleting it at all).
2. Since you new'ed an array, you need to delete an array.
delete [ ] filetext;
If you want to delete it in closeFile(), at least do this so the dtor is harmless
delete [ ] filetext;
filetext = 0;
And man, your comments are indented SO far off to the right as to be totally meaningless.
Finally, take out all those while() loops which are your 'fix' for the problem. Whatever the answer will be, you can be sure that the answer won't be using them.